****************************************************
*Where do UN Patrols Go? Exploring UNAMIS Response *
*to Violence in Darfur 							   *
*Luke Abbs (University of Essex)				   *	
*Allard Duursma (ETH-Zurich)					   *
****************************************************


***Analysis rerun with 25x25km grid-cells

use "Peackeeping_Darfur_25km_Grid_V1.6.dta"

tsset id duration

set more off

*create interactions
gen base_armedclash=un_base_dum*armedclash_dum
gen base_civtarget=un_base_dum*civtarget_dum
gen base_ngo=un_base_dum*ngo
gen base_idp=un_base_dum*no_idp_camp
gen troops_armedclash=notroops_log*armedclash_dum
gen troops_civtarget=notroops_log*civtarget_dum
gen troops_ngo=notroops_log*ngo
gen troops_idp=notroops_log*no_idp_camp
*

*****************************************
*Contents								*
*25km-Grid								*
*(1) main results - 25km-grid			*
*(2) Long-distance patrols - 25km-grid	*
*(3) proactive patrols - 25km-grid	    *			
*****************************************

**************
*Main Results*
**************

*************
* 25km Grid *
*************

*structured as following:
*model 1 - all variables with 25km-grid
*model 2 - all variables and interactions with 25km-grid

*Table 1

*models 2 and 4 UN patrols
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km, vce(cluster id)
eststo model3
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km base_armedclash base_civtarget base_ngo base_idp, vce(cluster id)
eststo model4
esttab model3 model4, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*table
esttab model3 model4 using table1b.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

*marginal effects

*full model
estsimp logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
setx mean 
simqi, pr
*.0003787

*armed violence dummy (1 versus 0)
setx armedclash_dum 0
simqi, pr
*.0003765 
setx armedclash_dum 1
simqi, pr
*.0015546  (313% increase - large increase of just over 3 times more likely...) 

*civtarget (no events versus at least 1 event)
setx civtarget_dum 0
simqi, pr
*.0015381  
setx civtarget_dum 1
simqi, pr
*.0067408 (338% increase - again just over 3 times more likely) 

*UN base dummy (1 versus 0)
setx un_base_dum 0
simqi, pr
*.0064408 
setx un_base_dum 1
simqi, pr
*.0191298 (197% increase - large increase of just under 2 times more likely...) 
drop b1 - b20

********************************************************
*Outside UN zones of influence/deployment (i.e. bunkers)*
*(long-distance UN Patrols							    *
*********************************************************

*Table 2

*model 7 patrols outside 15km
logit outside_15km_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol15 patrol15_spline1 patrol15_spline2 patrol15_spline3 patrol_spatial_lag un_spatial_lag_25km, vce(cluster id)
eststo model7
esttab model7, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*model 8 patrols outside 25km
***un_base limited as no 25km patrols occur in grids with UN bases
logit outside_25km_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol25 patrol25_spline1 patrol25_spline2 patrol25_spline3 patrol_spatial_lag un_spatial_lag_25km, vce(cluster id)
eststo model8
esttab model8, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*Table 2
esttab model7 model8 using table2b_longpatrols_eds.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*marginal effects

*full model
*gen civtarget_dum=civtarget
*recode civtarget_dum 1/1000=1
estsimp logit outside_25km_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol25 patrol25_spline1 patrol25_spline2 patrol25_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
setx mean 
simqi, pr
*.0001685 
*better prediction than 55km grids despite being rarer

*armed violence dummy (1 versus 0)
setx armedclash_dum 0
simqi, pr
*.0001673
setx armedclash_dum 1
simqi, pr
*.0010756  (increases to 523% or nearly six times more likely) 

*civtarget (no events versus at least 1 event)
setx civtarget_dum 0
simqi, pr
*.0010663
setx civtarget_dum 1
simqi, pr
*.0038404 (260% increase - nearly 4 times more likely) 
drop b1 - b19

*IDP camps (dummy)
gen idp_camp_dum=no_idp_camp
recode idp_camp_dum 1/18=1
estsimp logit outside_25km_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo idp_camp_dum chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol25 patrol25_spline1 patrol25_spline2 patrol25_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
setx mean
*no IDP camps
setx idp_camp_dum 0
simqi, pr
*.000119 
*vs. IDP camps
setx idp_camp_dum 1
simqi, pr
*.0004627 (289% increase - nearly 4 times more likely) 
drop b1 - b19

************************
* Proactive UN Patrols *
************************

*Table 3

*Proactive Patrols Only - counter reporting bias - more likely to be
*reported when violence occurs

*models 10 and 12

logit proactive_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 propatrol_spline3 patrol_spatial_lag un_spatial_lag_25km, vce(cluster id)
eststo model11
logit proactive_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 propatrol_spline3 patrol_spatial_lag un_spatial_lag_25km base_armedclash base_civtarget base_ngo base_idp, vce(cluster id)
eststo model12
esttab model11 model12, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*Table 3
esttab model11 model12 using table3b_proactive.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


***Long distance Proactive patrols?

*Proactive Patrols 15-25km for a UN base
gen proactive_dum15= proactive_dum+outside_15km_dum
recode proactive_dum15 1=0
recode proactive_dum15 2=1
gen proactive_dum25= proactive_dum+outside_25km_dum
recode proactive_dum25 1=0
recode proactive_dum25 2=1

*15km
logit proactive_dum15 un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 propatrol_spline3 patrol_spatial_lag un_spatial_lag_25km, vce(cluster id)
eststo modelpro1
logit proactive_dum15 un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 propatrol_spline3 patrol_spatial_lag un_spatial_lag_25km base_armedclash base_civtarget base_ngo base_idp, vce(cluster id)
eststo modelpro2
esttab modelpro1 modelpro2, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*25km
logit proactive_dum25 sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 propatrol_spline3 patrol_spatial_lag un_spatial_lag_25km, vce(cluster id)
eststo modelpro3
*25km interactions predict perfectly as none occur in grids with UN bases
esttab modelpro3, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


*******************
*Robustness Checks*
*******************

*Follow on from Table 3: Matching

ssc install cem
*matching armedclash_dum on 27.5km grid
imb un_base_dum sum_road_events ttime civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol, treatment(armedclash_dum)
cem un_base_dum sum_road_events ttime civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol, treatment(armedclash_dum)
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol [iweight=cem_weights], vce(cluster id)
eststo match1

*matching civtarget_dum on 27.5km grid
imb un_base_dum sum_road_events ttime armedclash_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol, treatment(civtarget_dum)
cem un_base_dum sum_road_events ttime armedclash_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol, treatment(civtarget_dum)
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol [iweight=cem_weights], vce(cluster id)
eststo match2

esttab match1 match2, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
esttab match1 match2 using matching_27km_grid.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*(1) Relative capacity of UN peacekeepers - changing UN base to number of troops

*models 1-2 rerun with number of troops in grid containing a base(s)
logit patrol_dum notroops_log sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km , vce(cluster id)
eststo model1r1
logit patrol_dum notroops_log sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km troops_armedclash troops_civtarget troops_ngo troops_idp, vce (cluster id)
eststo model2r1

esttab model1r1 model2r1, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
esttab model1r1 model2r1 using table_4R_25kmGrid.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*(2) Robust standard errors
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km, robust cluster (id)
eststo model1r2
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km base_armedclash base_civtarget base_ngo base_idp, robust cluster (id)
eststo model2r2
esttab model1r2 model2r2, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


*(3) Rare-events Logit

*install relogit
net install relogit, from(http://fmwww.bc.edu/RePEc/bocode/r)

gen l_armedclash_dum=l.armedclash_dum
gen l_civtarget_dum =l.civtarget_dum

relogit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l_armedclash_dum civtarget_dum l_civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km, cluster (id)
eststo model1r3
relogit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l_armedclash_dum civtarget_dum l_civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km base_armedclash base_civtarget base_ngo base_idp, cluster (id)
eststo model2r3
esttab model1r2 model2r2 model1r3 model2r3, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

esttab model1r2 model2r2 model1r3 model2r3 using table_5R_25kmGrid.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*(4) Inverse-Distance Spatial Lags

*Please see Spatial Tests Dofile. Inverse Lags in R at the bottom of this Dofile


* (5) Fixed Effects

clear
use "Peackeeping_Darfur_25km_Grid_V1.6.dta"
tsset id duration
set matsize 10000
set more off

*year fixed effects
xtlogit patrol_dum armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum weeks_since_patrol patrol_sp_lag i.duration, fe 
eststo FE1

*gid fixed effects
xtlogit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_since_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_spatial_lag un_spatial_lag_25km i.id, fe
eststo FE2

esttab FE1 FE2 using FE_25km_Grid.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

